#pragma once

#include"hash.h"

namespace HashBucket
{

	template<class K>
	class myset
	{
		struct SetKeyofT
		{
			const K& operator()(const K& k)
			{
				return k;
			}
		};


	public:
		typedef HashTable<K, K, SetKeyofT>  HT;
		typedef typename HashTable<K, K, SetKeyofT>::Iterator iterator;
		typedef typename HashTable<K, K, SetKeyofT>::const_Iterator const_iterator;

		iterator begin()
		{
			return _HT.Begin();
		}

		iterator end()
		{
			return _HT.End();
		}

		const_iterator begin() const
		{
			return _HT.Begin();
		}

		const_iterator end() const
		{
			return _HT.End();
		}

		pair<iterator, bool> insert(const K& data)
		{
			return _HT.Insert(data);
		}

		


	private:
		
		HashTable<K, K, SetKeyofT> _HT;
	};

	void testunorded_set()
	{
		myset<int> set1;
		
		
		set1.insert(1);
		set1.insert(2);
		set1.insert(3);
		set1.insert(4);
		myset<int>::iterator  it = set1.begin();
		while (it!=set1.end())
		{
			cout << *it<<" ";
			++it;

		}
		cout << endl;

		const myset<int> set2(set1);
		
		int a = 0;
		myset<int>::const_iterator it2 = set2.begin();

		//auto it2 = set2.begin();


		while (it2 != set2.end())
		{
			cout << *it2 << " ";
			++it2;
		}

	}
}
